﻿using System;

namespace HslCommunication.Core.IMessage
{
	/// <summary>
	/// 西门子Fetch/Write消息解析协议
	/// </summary>
	// Token: 0x02000154 RID: 340
	public class FetchWriteMessage : INetMessage
	{
		/// <inheritdoc cref="P:HslCommunication.Core.IMessage.INetMessage.ProtocolHeadBytesLength" />
		// Token: 0x170005CF RID: 1487
		// (get) Token: 0x06001D16 RID: 7446 RVA: 0x0008CFF3 File Offset: 0x0008B1F3
		public int ProtocolHeadBytesLength
		{
			get
			{
				return 16;
			}
		}

		/// <inheritdoc cref="M:HslCommunication.Core.IMessage.INetMessage.GetContentLengthByHeadBytes" />
		// Token: 0x06001D17 RID: 7447 RVA: 0x0008CFF8 File Offset: 0x0008B1F8
		public int GetContentLengthByHeadBytes()
		{
			bool flag = this.HeadBytes[5] == 5 || this.HeadBytes[5] == 4;
			int result;
			if (flag)
			{
				result = 0;
			}
			else
			{
				bool flag2 = this.HeadBytes[5] == 6;
				if (flag2)
				{
					bool flag3 = this.SendBytes == null;
					if (flag3)
					{
						result = 0;
					}
					else
					{
						bool flag4 = this.HeadBytes[8] > 0;
						if (flag4)
						{
							result = 0;
						}
						else
						{
							bool flag5 = this.SendBytes[8] == 1 || this.SendBytes[8] == 6 || this.SendBytes[8] == 7;
							if (flag5)
							{
								result = ((int)this.SendBytes[12] * 256 + (int)this.SendBytes[13]) * 2;
							}
							else
							{
								result = (int)this.SendBytes[12] * 256 + (int)this.SendBytes[13];
							}
						}
					}
				}
				else
				{
					bool flag6 = this.HeadBytes[5] == 3;
					if (flag6)
					{
						bool flag7 = this.HeadBytes[8] == 1 || this.HeadBytes[8] == 6 || this.HeadBytes[8] == 7;
						if (flag7)
						{
							result = ((int)this.HeadBytes[12] * 256 + (int)this.HeadBytes[13]) * 2;
						}
						else
						{
							result = (int)this.HeadBytes[12] * 256 + (int)this.HeadBytes[13];
						}
					}
					else
					{
						result = 0;
					}
				}
			}
			return result;
		}

		/// <inheritdoc cref="M:HslCommunication.Core.IMessage.INetMessage.CheckHeadBytesLegal(System.Byte[])" />
		// Token: 0x06001D18 RID: 7448 RVA: 0x0008D14C File Offset: 0x0008B34C
		public bool CheckHeadBytesLegal(byte[] token)
		{
			bool flag = this.HeadBytes == null;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				bool flag2 = this.HeadBytes[0] == 83 && this.HeadBytes[1] == 53;
				result = flag2;
			}
			return result;
		}

		/// <inheritdoc cref="M:HslCommunication.Core.IMessage.INetMessage.GetHeadBytesIdentity" />
		// Token: 0x06001D19 RID: 7449 RVA: 0x0008D193 File Offset: 0x0008B393
		public int GetHeadBytesIdentity()
		{
			return (int)this.HeadBytes[3];
		}

		/// <inheritdoc cref="P:HslCommunication.Core.IMessage.INetMessage.HeadBytes" />
		// Token: 0x170005D0 RID: 1488
		// (get) Token: 0x06001D1A RID: 7450 RVA: 0x0008D19D File Offset: 0x0008B39D
		// (set) Token: 0x06001D1B RID: 7451 RVA: 0x0008D1A5 File Offset: 0x0008B3A5
		public byte[] HeadBytes { get; set; }

		/// <inheritdoc cref="P:HslCommunication.Core.IMessage.INetMessage.ContentBytes" />
		// Token: 0x170005D1 RID: 1489
		// (get) Token: 0x06001D1C RID: 7452 RVA: 0x0008D1AE File Offset: 0x0008B3AE
		// (set) Token: 0x06001D1D RID: 7453 RVA: 0x0008D1B6 File Offset: 0x0008B3B6
		public byte[] ContentBytes { get; set; }

		/// <inheritdoc cref="P:HslCommunication.Core.IMessage.INetMessage.SendBytes" />
		// Token: 0x170005D2 RID: 1490
		// (get) Token: 0x06001D1E RID: 7454 RVA: 0x0008D1BF File Offset: 0x0008B3BF
		// (set) Token: 0x06001D1F RID: 7455 RVA: 0x0008D1C7 File Offset: 0x0008B3C7
		public byte[] SendBytes { get; set; }
	}
}
